<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
   {include="style"}
   {include="edit"}
  </head>
  
  <body>
	<div class="x-nav">
		<span class="layui-breadcrumb">
		  <a><cite>首页</cite></a>
		  <a><cite>管理员管理</cite></a>
		  <a><cite>新增管理员信息</cite></a>
		</span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
	</div>
    <div class="x-body">
	<div class="layui-card">
	    <div class="layui-card-body">
		<form class="layui-form layui-form-pane">
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>登录名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="name" name="name" required="" lay-verify="required"
                  autocomplete="off" value="" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>将会成为您唯一的登入名
              </div>
          </div>
          <div class="layui-form-item">
              <label for="tel" class="layui-form-label">
                  <span class="x-red"></span>手机
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="" id="tel" name="tel" required="" lay-verify="tel"
                  autocomplete="off" class="layui-input">
              </div>
              
          </div>
          <div class="layui-form-item">
              <label for="email" class="layui-form-label">
                  <span class="x-red"></span>邮箱
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="" id="email" name="email"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red"></span>
              </div>
          </div>
        
		 
          <div class="layui-form-item">
              <label class="layui-form-label"><span class="x-red">*</span>角色</label>
              <div class="layui-input-inline">
			  
                <select class="layui-input" name="gid" lay-filter="gid" lay-verify="required">
				<option value="">选择角色</option>
				{foreach $groups as $v}
				 {if($isadmin)}
				 <option value="{$v['id']}">{$v['name']}</option>
				 {else}
				 {if($v['id']!=1)}
				 <option value="{$v['id']}">{$v['name']}</option>
				 {/if}
				 {/if}
				
				{/foreach}
				
				</select>
              </div>
          </div>
		
		  <span id="ext_fields"></span>
				
				
		  
          <div class="layui-form-item">
              <label for="L_pass" class="layui-form-label">
                  <span class="x-red">*</span>密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="pass" required="" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  6到16个字符,不改请留空
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red">*</span>确认密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                  autocomplete="off" class="layui-input">
              </div>
			  <div class="layui-form-mid layui-word-aux">
                  6到16个字符,不改请留空
              </div>
          </div>
		  <div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-inline">
			  <select name="status" lay-verify="required">
				
				<option value="1">正常</option>
				<option value="0">禁用</option>
				
			  </select>
			</div>
		  </div>
		   <input type="hidden" id="go" name="go" value="1">
		   <input type="hidden" name="token" value="{$token}">
          <div class="layui-form-item" style="text-align:center;">
              
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  新增
              </button>
          </div>
      </form>
		</div>
    </div>
    </div>
    <script>
	{include="fields"}
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
         

          //监听提交
          form.on('submit(add)', function(data){
		  
		
           $.post("{fun U('adminadd')}",data.field,function(res){
				 var res = JSON.parse(res);
				
				 if(res.code==1){
					layer.msg(res.msg);
				 }else{
					 layer.msg("增加成功", {icon: 6,time: 2000},function () {
						// 获得frame索引
						 {if($webconf['admintpl']=='tpl')}
						   window.location.href="{fun U('adminlist')}";
						  {else}
						  var index = parent.layer.getFrameIndex(window.name);
							//关闭当前frame
							parent.layer.close(index);
							parent.location.href="{fun U('adminlist')}";
						  {/if}
						
						
					});
				 }
				 
			});
            return false;
          });
          
		   form.on('select(gid)', function(data){
			  /*
			  console.log(data.elem); //得到select原始DOM对象
			  console.log(data.value); //得到被选中的值
			  console.log(data.othis); //得到美化后的DOM对象
			  */
			  get_fields(data.value);
			});
          
        });
    </script>
   
  </body>

</html>